<template>
    <div class="blogDetail">
        <h2 style="margin-top: 58px;">{{blog.title}}</h2>
        <p v-html="blog.content" v-highlight class="content">
        </p>
        <p style="margin-left: 340px; margin-top: 80px; margin-bottom: 36px; float: right;">
            {{blog.updateTime}}
        </p>
    </div>
</template>

<script>

    import blogDetailApi from "@/api/blogDetail";
    import marked from "marked";

    let rendererMD = new marked.Renderer();
    marked.setOptions({
        renderer: rendererMD,
        gfm: true,
        tables: true,
        breaks: false,
        pedantic: false,
        sanitize: false,
        smartLists: true,
        smartypants: false
    });

    export default {
        name: "blog-detail",


        data() {
            return {
                blog: {
                    title: "",
                    content: "",
                    updateTime: "",
                },

            }
        },

        created() {
            this.getBlogDetail(this.$route.params.id);
        },

        methods: {
            getBlogDetail: function (id) {
                blogDetailApi.getBlogDetail(id).then(response => {
                    const resp = response.data;
                    if(resp.flag) {
                        this.blog.title = resp.data.title;
                        this.blog.content = marked(resp.data.content);
                        this.blog.updateTime = resp.data.updateTime;
                    }
                })
            }
        },
    }
</script>

<style>

    div.blogDetail {
        width: 80%;
    }

    /*添加自己喜欢的样式，也可以去网找一份*/
    .content h1, h2, h3, h4 {
        color: #111111;
        font-weight: 400;
        margin-top: 1em;
    }

    .content h1, h2, h3, h4, h5 {
        font-family: Georgia, Palatino, serif;
    }
    .content h1, h2, h3, h4, h5, dl{
        margin-bottom: 16px;
        padding: 0;
    }
    .content p {
        margin: 8px 0;
    }
    .content h1 {
        font-size: 48px;
        line-height: 54px;
    }
    .content h2 {
        font-size: 36px;
        line-height: 42px;
    }
    .content h1, h2 {
        border-bottom: 1px solid #EFEAEA;
        padding-bottom: 10px;
    }
    .content h3 {
        font-size: 24px;
        line-height: 30px;
    }
    .content h4 {
        font-size: 21px;
        line-height: 26px;
    }
    .content h5 {
        font-size: 18px;
        list-style: initial;
    }
    .content a {
        color: #0099ff;
        margin: 0;
        padding: 0;
        vertical-align: baseline;
    }
    .content a:hover {
        text-decoration: none;
        color: #ff6600;
    }
    .content a:visited {
        /*color: purple;*/
    }
    .content ul, ol {
        padding: 0;
        padding-left: 24px;
        margin: 0;
    }
    .content li {
        line-height: 24px;
    }
    .content p, ul, ol {
        font-size: 16px;
        line-height: 24px;
    }

    .content ol ol, ul ol {
        list-style-type: lower-roman;
    }

    .content pre {
        max-width: 800px;
        white-space: pre-wrap;
        line-height: 1.7em;
        overflow: auto;
        padding: 6px 10px;
    }

    .content aside {
        display: block;
        float: right;
        width: 390px;
    }
    .content blockquote {
        border-left:.5em solid #eee;
        padding: 0 0 0 2em;
        margin-left:0;
    }
    .content blockquote  cite {
        font-size:14px;
        line-height:20px;
        color:#bfbfbf;
    }
    .content  blockquote cite:before {
        content: '\2014 \00A0';
    }

    .content blockquote p {
        color: #666;
    }
    .content hr {
        text-align: left;
        color: #999;
        height: 2px;
        padding: 0;
        margin: 16px 0;
        background-color: #e7e7e7;
        border: 0 none;
    }

    .content dl {
        padding: 0;
    }

    .content dl dt {
        padding: 10px 0;
        margin-top: 16px;
        font-size: 1em;
        font-style: italic;
        font-weight: bold;
    }

    .content dl dd {
        padding: 0 16px;
        margin-bottom: 16px;
    }

    .content dd {
        margin-left: 0;
    }

    /* Code below this line is copyright Twitter Inc. */

    .content button,
    input,
    select,
    textarea {
        font-size: 100%;
        margin: 0;
        vertical-align: baseline;
        *vertical-align: middle;
    }
    .content button, input {
        line-height: normal;
        *overflow: visible;
    }
    .content button::-moz-focus-inner, input::-moz-focus-inner {
        border: 0;
        padding: 0;
    }
    .content button,
    input[type="button"],
    input[type="reset"],
    input[type="submit"] {
        cursor: pointer;
        -webkit-appearance: button;
    }
    .content input[type=checkbox], input[type=radio] {
        cursor: pointer;
    }
    /* override default chrome & firefox settings */
    .content input:not([type="image"]), textarea {
        -webkit-box-sizing: content-box;
        -moz-box-sizing: content-box;
        box-sizing: content-box;
    }

    .content input[type="search"] {
        -webkit-appearance: textfield;
        -webkit-box-sizing: content-box;
        -moz-box-sizing: content-box;
        box-sizing: content-box;
    }
    .content input[type="search"]::-webkit-search-decoration {
        -webkit-appearance: none;
    }
    .content label,
    input,
    select,
    textarea {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 13px;
        font-weight: normal;
        line-height: normal;
        margin-bottom: 18px;
    }
    .content input[type=checkbox], input[type=radio] {
        cursor: pointer;
        margin-bottom: 0;
    }
    .content input[type=text],
    input[type=password],
    textarea,
    select {
        display: inline-block;
        width: 210px;
        padding: 4px;
        font-size: 13px;
        font-weight: normal;
        line-height: 18px;
        height: 18px;
        color: #808080;
        border: 1px solid #ccc;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
    }
    .content select, input[type=file] {
        height: 27px;
        line-height: 27px;
    }
    .content textarea {
        height: auto;
    }
    /* grey out placeholders */
    .content :-moz-placeholder {
        color: #bfbfbf;
    }
    .content ::-webkit-input-placeholder {
        color: #bfbfbf;
    }
    .content input[type=text],
    .content input[type=password],
    .content select,
    .content textarea {
        -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
        -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
        transition: border linear 0.2s, box-shadow linear 0.2s;
        -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
        -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    .content input[type=text]:focus, input[type=password]:focus, textarea:focus {
        outline: none;
        border-color: rgba(82, 168, 236, 0.8);
        -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);
        -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);
    }
    /* buttons */
    .content button {
        display: inline-block;
        padding: 4px 14px;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 13px;
        line-height: 18px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        background-color: #0064cd;
        background-repeat: repeat-x;
        background-image: -moz-linear-gradient(top, #049cdb, #0064cd);
        background-image: -ms-linear-gradient(top, #049cdb, #0064cd);
        background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));
        background-image: -webkit-linear-gradient(top, #049cdb, #0064cd);
        background-image: -o-linear-gradient(top, #049cdb, #0064cd);
        background-image: linear-gradient(top, #049cdb, #0064cd);
        color: #fff;
        text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
        border: 1px solid #004b9a;
        border-bottom-color: #003f81;
        -webkit-transition: 0.1s linear all;
        -moz-transition: 0.1s linear all;
        transition: 0.1s linear all;
        border-color: #0064cd #0064cd #003f81;
        border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
    }
    .content button:hover {
        color: #fff;
        background-position: 0 -15px;
        text-decoration: none;
    }
    .content button:active {
        -webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
        -moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
        box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
    }
    .content button::-moz-focus-inner {
        padding: 0;
        border: 0;
    }
    .content table {
        *border-collapse: collapse; /* IE7 and lower */
        border-spacing: 0;
        width: 100%;
    }
    .content table {
        border: solid #ccc 1px;
        -moz-border-radius: 6px;
        -webkit-border-radius: 6px;
        border-radius: 6px;
        /*-webkit-box-shadow: 0 1px 1px #ccc;
        -moz-box-shadow: 0 1px 1px #ccc;
        box-shadow: 0 1px 1px #ccc;   */
    }
    .content table tr:hover {
        background: #fbf8e9;
        -o-transition: all 0.1s ease-in-out;
        -webkit-transition: all 0.1s ease-in-out;
        -moz-transition: all 0.1s ease-in-out;
        -ms-transition: all 0.1s ease-in-out;
        transition: all 0.1s ease-in-out;
    }
    .content table td, .table th {
        border-left: 1px solid #ccc;
        border-top: 1px solid #ccc;
        padding: 10px;
        text-align: left;
    }

    .content table th {
        background-color: #dce9f9;
        background-image: -webkit-gradient(linear, left top, left bottom, from(#ebf3fc), to(#dce9f9));
        background-image: -webkit-linear-gradient(top, #ebf3fc, #dce9f9);
        background-image:    -moz-linear-gradient(top, #ebf3fc, #dce9f9);
        background-image:     -ms-linear-gradient(top, #ebf3fc, #dce9f9);
        background-image:      -o-linear-gradient(top, #ebf3fc, #dce9f9);
        background-image:         linear-gradient(top, #ebf3fc, #dce9f9);
        /*-webkit-box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
        -moz-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;
        box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;*/
        border-top: none;
        text-shadow: 0 1px 0 rgba(255,255,255,.5);
        padding: 5px;
    }

    .content table td:first-child, table th:first-child {
        border-left: none;
    }

    .content table th:first-child {
        -moz-border-radius: 6px 0 0 0;
        -webkit-border-radius: 6px 0 0 0;
        border-radius: 6px 0 0 0;
    }
    .content table th:last-child {
        -moz-border-radius: 0 6px 0 0;
        -webkit-border-radius: 0 6px 0 0;
        border-radius: 0 6px 0 0;
    }
    .content table th:only-child{
        -moz-border-radius: 6px 6px 0 0;
        -webkit-border-radius: 6px 6px 0 0;
        border-radius: 6px 6px 0 0;
    }
    .content table tr:last-child td:first-child {
        -moz-border-radius: 0 0 0 6px;
        -webkit-border-radius: 0 0 0 6px;
        border-radius: 0 0 0 6px;
    }
    .content table tr:last-child td:last-child {
        -moz-border-radius: 0 0 6px 0;
        -webkit-border-radius: 0 0 6px 0;
        border-radius: 0 0 6px 0;
    }

</style>
